package com.cat.recruit.controller;

import com.cat.recruit.common.result.Result;
import com.cat.recruit.service.impl.JwtUserDetailsServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用于处理token的controller
 */
@Tag(name = "Token模块")
@RestController
@RequestMapping("/api/token")
public class TokenController {
    private final JwtUserDetailsServiceImpl jwtUserDetailsServiceImpl;

    public TokenController(JwtUserDetailsServiceImpl jwtUserDetailsServiceImpl) {
        this.jwtUserDetailsServiceImpl = jwtUserDetailsServiceImpl;
    }

    /**
     * 刷新token
     */
    @Operation(summary = "刷新token", description = "刷新token")
    @PostMapping("/refreshToken")
    public Result refreshToken(
            @Parameter(description = "刷新token所需的refreshToken", required = true)
            String refreshToken
    ) {
        return jwtUserDetailsServiceImpl.refreshToken(refreshToken);
    }
}
